﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using Newtonsoft.Json;
using Model;
using DAL;
using System.IO;
using Core;
using System.ServiceModel.Activation;

namespace Alos.Service
{
    // 注意: 使用“重构”菜单上的“重命名”命令，可以同时更改代码和配置文件中的类名“Operation”。
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class Operation : IOperation
    {
        public string DownLession(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "备课同步请求成功！" };
            var la = data.ToEntity<LessonAccept>();
            DAL.ReResource ReResourceService = new DAL.ReResource();
            new ReLessionDAL().DownLession(la.id, la.type, la.laeid);
            return StreamHelper.ToJsonResult(rtnObj);
        }

        public string AddTeacherAction(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "老师行为提交成功！" };
            var rscr = data.ToEntity<ReTeacherRecord>();
            ReTeacherRecordDAL.SaveEntity(rscr);
            rtnObj.data = JsonConvert.SerializeObject(rscr);
            return StreamHelper.ToJsonResult(rtnObj);
        }

        public string AddStudentAction(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "学生行为提交成功！" };
            var rscr = data.ToEntity<ReStudentClassRecord>();
            rscr.StartTime = DateTime.Now;
            ReStudentClassRecordDAL.SaveEntity(rscr);
            rtnObj.data = JsonConvert.SerializeObject(rscr);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddResourceRecord(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "资源使用记录提交成功！" };
            var rscr = data.ToEntity<ReResourceRecord>();
            rscr.RecordTime = DateTime.Now;
            ReResourceRecordDAL.SaveEntity(rscr);
            rtnObj.data = JsonConvert.SerializeObject(rscr);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddResourceEvaluateRecord(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "资源评价记录提交成功！" };
            var rscr = data.ToEntity<ReResourceEvaluateRecord>();
            rscr.RecordTime = DateTime.Now;
            ReResourceEvaluateRecordDAL.SaveEntity(rscr);
            rtnObj.data = JsonConvert.SerializeObject(rscr);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddReClassSign(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "学生课堂标记录提交成功！" };
            var res = data.ToEntity<ReClassSign>();
            res.SignTime = DateTime.Now;
            ReClassSignDAL.SaveEntity(res);
            rtnObj.data = JsonConvert.SerializeObject(res);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddReDiscuss(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "课堂研讨教学记录提交成功！" };
            var res = data.ToEntity<ReDiscuss>();
            ReDiscussDAL.SaveEntity(res);
            rtnObj.data = JsonConvert.SerializeObject(res);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddReActivityDetail(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "活动详情记录提交成功！" };
            var res = data.ToEntity<ReActivityDetail>();
            ReActivityDetailDAL.SaveEntity(res);
            rtnObj.data = JsonConvert.SerializeObject(res);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddReActivity(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "活动详情记录提交成功！" };
            var res = data.ToEntity<ReActivity>();
            ReActivityDAL.SaveEntity(res);
            rtnObj.data = JsonConvert.SerializeObject(res);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddReWhiteBroadDetail(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "白板互动详情记录提交成功！" };
            var res = data.ToEntity<ReWhiteBroadDetail>();
            ReWhiteBroadDetailDAL.SaveEntity(res);
            rtnObj.data = JsonConvert.SerializeObject(res);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddReWhiteBroad(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "白板互动记录提交成功！" };
            var res = data.ToEntity<ReWhiteBroad>();
            ReWhiteBroadDAL.SaveEntity(res);
            rtnObj.data = JsonConvert.SerializeObject(res);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddReExamDetail(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "学生试题答题详情记录提交成功！" };
            var res = data.ToEntity<ReExamDetail>();
            ReExamDetailDAL.SaveEntity(res);
            rtnObj.data = JsonConvert.SerializeObject(res);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddReExamSubmit(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "学生课堂测验提交记录提交成功！" };
            var res = data.ToEntity<ReExamSubmit>();
            ReExamSubmitDAL.SaveEntity(res);
            rtnObj.data = JsonConvert.SerializeObject(res);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddReExamSubject(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "课堂测验题目记录提交成功！" };
            var res = data.ToEntity<ReExamSubject>();
            ReExamSubjectDAL.SaveEntity(res);
            rtnObj.data = JsonConvert.SerializeObject(res);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddReExam(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "课堂测验记录提交成功！" };
            var res = data.ToEntity<ReExam>();
            ReExamDAL.SaveEntity(res);
            rtnObj.data = JsonConvert.SerializeObject(res);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddReVoteDetail(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "学生课堂投票详情记录提交成功！" };
            var res = data.ToEntity<ReVoteDetail>();
            ReVoteDetailDAL.SaveEntity(res);
            rtnObj.data = JsonConvert.SerializeObject(res);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddReVote(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "学生课堂投票记录提交成功！" };
            var res = data.ToEntity<ReVote>();
            ReVoteDAL.SaveEntity(res);
            rtnObj.data = JsonConvert.SerializeObject(res);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddRePutQuestionDetail(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "学生课堂问答详情记录提交成功！" };
            var res = data.ToEntity<RePutQuestionDetail>();
            RePutQuestionDetailDAL.SaveEntity(res);
            rtnObj.data = JsonConvert.SerializeObject(res);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddRePutQuestion(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "学生课堂问答记录提交成功！" };
            var res = data.ToEntity<RePutQuestion>();
            RePutQuestionDAL.SaveEntity(res);
            rtnObj.data = JsonConvert.SerializeObject(res);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddReFeedbackDetail(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "学生课堂反馈记录详情记录提交成功！" };
            var res = data.ToEntity<ReFeedbackDetail>();
            ReFeedbackDetailDAL.SaveEntity(res);
            rtnObj.data = JsonConvert.SerializeObject(res);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddReFeedbackBatch(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "学生课堂反馈批次记录提交成功！" };
            var res = data.ToEntity<ReFeedbackBatch>();
            ReFeedbackBatchDAL.SaveEntity(res);
            rtnObj.data = JsonConvert.SerializeObject(res);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddResorceInvate(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "课堂心跳记录提交成功！" };
            var res = data.ToEntity<ResorceInvate>();
            ResorceInvateDAL.SaveEntity(res);
            rtnObj.data = JsonConvert.SerializeObject(res);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddReArrangeRecord(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "发布记录提交成功！" };
            var res = data.ToEntity<ReArrangeRecord>();
            ReArrangeRecordDAL.SaveEntity(res);
            rtnObj.data = JsonConvert.SerializeObject(res);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddReSubmitRecord(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "学生提交记录提交成功！" };
            var res = data.ToEntity<ReSubmitRecord>();
            ReSubmitRecordDAL.SaveEntity(res);
            rtnObj.data = JsonConvert.SerializeObject(res);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddReObjectiveQuestion(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "学生提交客观题记录提交成功！" };
            var res = data.ToEntity<ReObjectiveQuestion>();
            ReObjectiveQuestionDAL.SaveEntity(res);
            rtnObj.data = JsonConvert.SerializeObject(res);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddReSubjectiveQuestion(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "学生提交主观题记录提交成功！" };
            var res = data.ToEntity<ReSubjectiveQuestion>();
            ReSubjectiveQuestionDAL.SaveEntity(res);
            rtnObj.data = JsonConvert.SerializeObject(res);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddStudentNoteProblem(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "学生疑惑笔记记录提交成功！" };
            var res = data.ToEntity<StudentNoteProblem>();
            StudentNoteProblemDAL.SaveEntity(res);
            rtnObj.data = JsonConvert.SerializeObject(res);
            return StreamHelper.ToJsonResult(rtnObj);
        }
        public string AddStudentNoteProblemComment(Stream data)
        {
            var rtnObj = new RtnObj<string>() { code = 200, sucess = true, data = null, message = "学生疑惑笔记评论记录提交成功！" };
            var res = data.ToEntity<StudentNoteProblemComment>();
            StudentNoteProblemCommentDAL.SaveEntity(res);
            rtnObj.data = JsonConvert.SerializeObject(res);
            return StreamHelper.ToJsonResult(rtnObj);
        }
    }
}
